home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / igstate.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  7.4 KB  |  205 lines

  1. /* Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: igstate.h,v 1.3 2000/09/19 19:00:44 lpd Exp $ */
  20. /* Interpreter graphics state definition */
  21.  
  22. #ifndef igstate_INCLUDED
  23. #  define igstate_INCLUDED
  24.  
  25. #include "gsstate.h"
  26. #include "gxstate.h"        /* for 'client data' access */
  27. #include "imemory.h"
  28. #include "istruct.h"        /* for gstate obj definition */
  29.  
  30. /*
  31.  * From the interpreter's point of view, the graphics state is largely opaque,
  32.  * i.e., the interpreter is just another client of the library.
  33.  * The interpreter does require additional items in the graphics state;
  34.  * these are "client data" from the library's point of view.
  35.  * Most of the complexity in this added state comes from
  36.  * the parameters associated with the various Level 2 color spaces.
  37.  * Note that the added information consists entirely of refs.
  38.  */
  39.  
  40. /*
  41.  * The interpreter represents graphics state objects in a slightly
  42.  * unnatural way, namely, by a t_astruct ref that points to an object
  43.  * of type st_igstate_obj, which is essentially a t_struct ref that in turn
  44.  * points to a real graphics state (object of type st_gs_state).
  45.  * We do this so that save and restore can manipulate the intermediate
  46.  * object and not have to worry about copying entire gs_states.
  47.  *
  48.  * Because a number of different operators must test whether an object
  49.  * is a gstate, we make an exception to our convention of declaring
  50.  * structure descriptors only in the place where the structure itself
  51.  * is defined (see gsstruct.h for more information on this).
  52.  */
  53. typedef struct igstate_obj_s {
  54.     ref gstate;            /* t_struct / st_gs_state */
  55. } igstate_obj;
  56.  
  57. extern_st(st_igstate_obj);
  58. #define public_st_igstate_obj()    /* in zdps1.c */\
  59.   gs_public_st_ref_struct(st_igstate_obj, igstate_obj, "gstatetype")
  60. #define igstate_ptr(rp) r_ptr(&r_ptr(rp, igstate_obj)->gstate, gs_state)
  61.  
  62. /* DeviceN names and tint transform */
  63. typedef struct ref_device_n_params_s {
  64.     ref layer_names, tint_transform;
  65. } ref_device_n_params;
  66.  
  67. /* CIE transformation procedures */
  68. typedef struct ref_cie_procs_s {
  69.     union {
  70.     ref DEFG;
  71.     ref DEF;
  72.     } PreDecode;
  73.     union {
  74.     ref ABC;
  75.     ref A;
  76.     } Decode;
  77.     ref DecodeLMN;
  78. } ref_cie_procs;
  79.  
  80. /* CIE rendering transformation procedures */
  81. typedef struct ref_cie_render_procs_s {
  82.     ref TransformPQR, EncodeLMN, EncodeABC, RenderTableT;
  83. } ref_cie_render_procs;
  84.  
  85. /* Separation name and tint transform */
  86. typedef struct ref_separation_params_s {
  87.     ref layer_name, tint_transform;
  88. } ref_separation_params;
  89.  
  90. /* All color space parameters. */
  91. /* All of these are optional. */
  92. /* Note that they may actually be the parameters for an underlying or */
  93. /* alternate space for a special space. */
  94. typedef struct ref_color_procs_s {
  95.     ref_cie_procs cie;
  96.     union {
  97.     ref_device_n_params device_n;
  98.     ref_separation_params separation;
  99.     ref index_proc;
  100.     } special;
  101. } ref_color_procs;
  102. typedef struct ref_colorspace_s {
  103.     ref array;            /* color space (array), only relevant if */
  104.                 /* the current color space has parameters */
  105.                 /* associated with it. */
  106.     ref_color_procs procs;    /* associated procedures/parameters, */
  107.                 /* only relevant for DeviceN, CIE, */
  108.                 /* Separation, Indexed/CIE, */
  109.                 /* Indexed with procedure, or a Pattern */
  110.                 /* with one of these. */
  111. } ref_colorspace;
  112.  
  113. #ifndef int_remap_color_info_DEFINED
  114. #  define int_remap_color_info_DEFINED
  115. typedef struct int_remap_color_info_s int_remap_color_info_t;
  116. #endif
  117.  
  118. typedef struct int_gstate_s {
  119.     ref dash_pattern;        /* (array) */
  120.     /* Screen_procs are only relevant if setscreen was */
  121.     /* executed more recently than sethalftone */
  122.     /* (for this graphics context). */
  123.     union {
  124.     ref indexed[4];
  125.     struct {
  126.         /* The components must be in this order: */
  127.         ref red, green, blue, gray;
  128.     } colored;
  129.     } screen_procs,        /* halftone screen procedures */
  130.           transfer_procs;    /* transfer procedures */
  131.     ref black_generation;    /* (procedure) */
  132.     ref undercolor_removal;    /* (procedure) */
  133.     ref_colorspace colorspace;
  134.     /*
  135.      * Pattern is relevant only if the current color space
  136.      * is a pattern space.
  137.      */
  138.     ref pattern;        /* pattern (dictionary) */
  139.     struct {
  140.     ref dict;        /* CIE color rendering dictionary */
  141.     ref_cie_render_procs procs;    /* (see above) */
  142.     } colorrendering;
  143.     /*
  144.      * Halftone is relevant only if sethalftone was executed
  145.      * more recently than setscreen for this graphics context.
  146.      * setscreen sets it to null.
  147.      */
  148.     ref halftone;        /* halftone (dictionary) */
  149.     /*
  150.      * Pagedevice is only relevant if setpagedevice was executed more
  151.      * recently than nulldevice, setcachedevice, or setdevice with a
  152.      * non-page device (for this graphics context).  If the current device
  153.      * is not a page device, pagedevice is null.
  154.      */
  155.     ref pagedevice;        /* page device (dictionary|null) */
  156.     /*
  157.      * Remap_color_info is used temporarily to communicate the need for
  158.      * Pattern or DeviceNcolor remapping to the interpreter.  See
  159.      * e_RemapColor in errors.h.  The extra level of indirection through a
  160.      * structure is needed because the gstate passed to the PaintProc is
  161.      * different from the current gstate in the graphics state, and because
  162.      * the DeviceN color being remapped is not necessarily the current color
  163.      * in the graphics state (for shading or images): the structure is
  164.      * shared, so that the interpreter can get its hands on the remapping
  165.      * procedure.
  166.      */
  167.     ref remap_color_info;    /* t_struct (int_remap_color_info_t) */
  168.     /*
  169.      * The opacity and shape masks are a PDF 1.4 transparency feature,
  170.      * not standard PostScript.
  171.      */
  172.     ref opacity_mask, shape_mask; /* dictionary|null */
  173. } int_gstate;
  174.  
  175. #define clear_pagedevice(pigs) make_null(&(pigs)->pagedevice)
  176. /*
  177.  * Even though the interpreter's part of the graphics state actually
  178.  * consists of refs, allocating it as refs tends to create sandbars;
  179.  * since it is always allocated and freed as a unit, we can treat it
  180.  * as an ordinary structure.
  181.  */
  182. #define private_st_int_gstate()    /* in zgstate.c */\
  183.   gs_private_st_ref_struct(st_int_gstate, int_gstate, "int_gstate")
  184.  
  185. /* Enumerate the refs in an int_gstate. */
  186. /* Since all the elements of an int_gstate are refs, this is simple. */
  187. #define int_gstate_map_refs(p,m)\
  188.  { register ref *rp_ = (ref *)(p);\
  189.    register int i = sizeof(int_gstate) / sizeof(ref);\
  190.    do { m(rp_); ++rp_; } while ( --i );\
  191.  }
  192.  
  193. /* Create the gstate for a new context. */
  194. /* We export this so that fork can use it. */
  195. gs_state *int_gstate_alloc(P1(const gs_dual_memory_t * dmem));
  196.  
  197. /* Get the int_gstate from a gs_state. */
  198. #define gs_int_gstate(pgs) ((int_gstate *)gs_state_client_data(pgs))
  199.  
  200. /* The current instances for operators. */
  201. #define igs (i_ctx_p->pgs)
  202. #define istate gs_int_gstate(igs)
  203.  
  204. #endif /* igstate_INCLUDED */
  205.